package drds.binlog.parse.inbound;

import drds.binlog.parse.driver.packets.GtidSet;

import java.io.IOException;

/**
 * 通用的Erosa的链接接口, 用于一般化处理mysql/oracle的解析过程
 */
public interface Connection
{

    public void connect() throws IOException;

    public void reconnect() throws IOException;

    public void disconnect() throws IOException;

    /**
     * 用于快速数据查找,和dump的区别在于，seek会只给出部分的数据
     */
    public void seek(String binlogFileName, Long binlogPosition, SinkFunction sinkFunction) throws IOException;

    public void dump(String binlogFileName, Long binlogPosition, SinkFunction sinkFunction) throws IOException;

    public void dump(long timestamp, SinkFunction sinkFunction) throws IOException;

    /**
     * 通过GTID同步binlog
     */
    public void dump(GtidSet gtidSet, SinkFunction sinkFunction) throws IOException;

    // -------------

    public void dump(String binlogFileName, Long binlogPosition, IMultiStageCoprocessor IMultiStageCoprocessor) throws IOException;

    public void dump(long timestamp, IMultiStageCoprocessor IMultiStageCoprocessor) throws IOException;

    public void dump(GtidSet gtidSet, IMultiStageCoprocessor IMultiStageCoprocessor) throws IOException;

    Connection fork();

    public long queryServerId() throws IOException;
}
